package com.copm.demonstrationsystem.dao.introductionfeatures.landscape;

import com.copm.demonstrationsystem.pojo.introductionfeatures.landscape.LandscapeTypeImage;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: Yuan Baiyu
 * @Date: Created in 16:31 2018/5/5
 */
@Repository
public interface LandscapeTypeImageDao extends JpaRepository<LandscapeTypeImage,Long> {

    /**
     * 1、查找指定位置的所有公共设施图片
     * 2、图片的种类为 1
     * @param placeTypeId：不同位置类型图片的id
     * @return
     */
    @Query(value = "SELECT * FROM landscape_type_image WHERE place_type_id =?1 AND image_kind = 1",nativeQuery = true)
    List<LandscapeTypeImage> findServiceByPlaceTypeId(@Param("placeTypeId")Long placeTypeId);

    /**
     * 1、查找指定位置的所有园林美景图片
     * 2、图片的种类为 2
     * @param placeTypeId：不同位置类型图片的id
     * @return
     */
    @Query(value = "SELECT * FROM landscape_type_image WHERE place_type_id =?1 AND image_kind = 2",nativeQuery = true)
    List<LandscapeTypeImage> findParkImageByPlaceTypeId(@Param("placeTypeId")Long placeTypeId);

    //查找指定的园林景观或者周边设施全部图片
    List<LandscapeTypeImage> findByImageKind(Long id);

    //通过图片外键查找
    LandscapeTypeImage findByImage_Id(Long id);


    List<LandscapeTypeImage> findByPlaceTypeId(Long id);

    void deleteByPlaceTypeId(Long id);
}
